extends "../ib.gd"
var cnt
var cnt2
var cell
func init():
	.init()
	name = "竖琴"
	resetdata()
	att.maxHp = 188
	att.def = 40
	att.mgiDef = 40
	info = "琴音普发：自己无法行动和普攻，每秒为距离自己2格范围内所有友军（除自己）治疗<8%自身生命上限（最低33）>点血量，持续2s[cd:5秒]\n"
#根据等级增加属性
func addatt():
	att.maxHp += 288
	att.dod += 0.05
#链接信号
func _connect():
	._connect()
	yield(sys.get_tree().create_timer(0.05),"timeout")
	if !masCha:return
	sys.main.connect("onBattleStart",self,"resetcnt")
	if !masCha.is_connected("onAddItem",self,"check"):
		masCha.connect("onAddItem",self,"check")
#检查是否只有一双鞋
func check(item):
	yield(sys.get_tree().create_timer(0.02),"timeout")
	if item.id.find("harp") != -1 && item != self:
		masCha.delItem(item)
		sys.newBaseMsg("提示","一个角色只能装备一把竖琴")
#重置技能计数
func resetcnt():
	cnt = 0
	cnt2 = 0
#进化装备
func upgradeself(item):
	var chose = item.chose
	var c = str(chose)
	var upid = "_Hide_MAX"
	upid = self.id + upid
	self.switchchose(chose)
	var nitem = sys.newItem(upid)
	sys.main.player.addItem(nitem)
	masCha.disconnect("onAddItem",self,"check")
	masCha.addItem(nitem)
	nitem.inheritatt(nitem,self)
	nitem.addatt()
	nitem.upinfo()
	self.delself()

#技能计时
func _upS():
	._upS()
	cnt += 1
	if cnt == 5:
		cnt = 0
		masCha.addBuff(QYPF.new(1))

class QYPF:
	extends Buff
	var canremove:bool = false
	var tmp
	func _init(lv):
		attInit()
		life = 2.0
		id = "QYPF"
	func _connect():
		tmp = masCha.aiOn
		masCha.aiOn = false
		
	func _del():
		masCha.aiOn = tmp

	func _upS():
		var chas = masCha.getAllChas(2)
		for i in chas:
			if i == masCha:continue
			var x = abs(i.cell.x - masCha.cell.x)
			var y = abs(i.cell.y - masCha.cell.y)
			if x*x + y*y <= 4:
				masCha.healCha(i,max(33,masCha.att.maxHp * 0.08))